//
//  CustomLTView.m
//  UI09_homework
//
//  Created by aaaaaa on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomLTView.h"

@interface CustomLTView ()<UITextFieldDelegate>

@property (nonatomic, retain) UILabel *leftLable;
@property (nonatomic, retain) UITextField *rightTextField;

@end

@implementation CustomLTView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    self.leftLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds) * 0.3, CGRectGetHeight(self.bounds))];
    [self addSubview:self.leftLable];
    [_lableText release];
    
    self.rightTextField = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.bounds) * 0.3, 0, CGRectGetWidth(self.bounds) * 0.7, CGRectGetHeight(self.bounds))];
    
    self.rightTextField.delegate = self;
    self.rightTextField.layer.borderWidth = 1.0;
    self.rightTextField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.rightTextField.layer.cornerRadius = 5;
    
    [self addSubview:self.rightTextField];
    [_rightTextField release];
    
}

- (void)setLableText:(NSString *)lableText{
    if (_lableText != lableText) {
        [_lableText release];
        _lableText = [lableText retain];
    }
    
    self.leftLable.text = _lableText;
}


- (void)setTextFieldPlaceHolder:(NSString *)textFieldPlaceHolder{
    if (_textFieldPlaceHolder != textFieldPlaceHolder) {
        [_textFieldPlaceHolder release];
        _textFieldPlaceHolder = [textFieldPlaceHolder retain];
    }
    
    self.rightTextField.placeholder = _textFieldPlaceHolder;
}

- (void)setSecureTextEntry:(BOOL)secureTextEntry{
    if (secureTextEntry) {
        self.rightTextField.secureTextEntry = YES;
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [textField resignFirstResponder];
    return YES;
}














@end
